<?php
require './include/global.php';
require './include/validate.php';
require './include/all_left.php';

require_once './include/advisory_db.php';
//print_r($_SESSION);
$smarty->compile_check = true;
$safecode  = myf(10);


$rs = $DB->fetch_one_array("SELECT * FROM pa_resume WHERE re_uid = '".$_GET[uid]."' AND re_id = '".$_GET[id]."'");
if(empty($rs)){
   echo "<meta http-equiv=\"refresh\" content=\"0;URL=errorall.php?errid=rc_1008\">";
   exit;
}
//insert
$jobarr = getJobDetail($_GET[jid]);
$recarr = getRecruiterDetail($_SESSION[uid]);
$resarr = getResumeDetail($_GET[id]);


$invarr = $DB->fetch_one_array("SELECT * FROM pa_invite WHERE in_jobid = '".trim($_GET[jid])."' AND in_recruiterid = '".trim($_GET[uid])."' AND in_resumeid = '".$_GET[id]."'");
if(empty($invarr)){
	$sql = "INSERT INTO `pa_invite` ( `in_jobid` , `in_recruiterid` , `in_resumeid` , `in_status`,`in_vdate`,`in_jobstatus` ,`in_safecode`,`in_epname`,`in_rcname`,`in_rename`,`in_rcemail`,`in_reemail`,`in_jobtitle`,`in_jobsalary`,`in_regtime`)VALUES ('".trim($_GET[jid])."', '".trim($_GET[uid])."', '".trim($_GET[id])."', '3','".$jobarr[jo_vdate]."','".$jobarr[jo_status]."' ,'".$safecode."','".$jobarr[jo_copname]."','".$recarr[rc_fname]." ".$recarr[rc_lname]."','".$resarr[re_fname]." ".$resarr[re_lname]."','".$recarr[rc_email]."','".$resarr[re_email]."','".$jobarr[jo_title]."','".$jobarr[jo_salrange]."','".time()."')";
	$DB->query($sql);
}elseif($_GET[re]==1){
    $DB->query("UPDATE `pa_invite` SET in_safecode = '".$safecode."' , `in_resend` = `in_resend` + 1 WHERE in_id = '".$invarr[in_id]."' ");
}else{
   echo "<meta http-equiv=\"refresh\" content=\"0;URL=errorall.php?errid=rc_1009&return=$_GET[jid]\">";
   exit;
}

//print_r($jobarr);
//print_r($recarr);
//mail content


$subject  = $jobarr[jo_title] ." at ".$jobarr[jo_copname].", Certification and Authorization Email";
$content  = "Dear ".$resarr[re_fname].",<br><br>
I’m contacting you about a new job opportunity.  Please see the job details below.  In order for me to pursue this opportunity for you, I’m inviting you to certify that you have not already interviewed or communicated with the employer about this position, and authorize me to recommend you to the employer of this position.  If you are interested in pursuing this job opportunity please respond promptly.  Please do not respond by replying to this email.  <br><br>

To respond, simply click on the link below  to go to an online Certification and Authorization form (or copy and paste the URL link to your browser).  <br><br>

http://www.enetrecruiter.com/jobcertification.php?sf=".$safecode ."   <br><br>

If you have any questions, please contact me.<br><br>

Best regards,<br>
".$recarr[rc_fname]." ".$recarr[rc_lname]."<br>
".$recarr[rc_phone]."<br>

<hr>

Job Details<br><br>

Employer Company Name: ".$jobarr[jo_copname]."<br>
ER Job Req #: ".$jobarr[jo_id]."<br>
Job Title: ".$jobarr[jo_title]."<br>
Base Salary: ".$salary [$jobarr[jo_salrange]]."<br>
Job Description: <br>".$jobarr[jo_description]."<br><br>

NOTE: If you receive this email in error, please contact the sender and delete it from your computer.  Thank you.

";




$headers .= "From:  ".$recarr[rc_fname]." ".$recarr[rc_lname] ."<".$recarr[rc_email].">" . "\r\n";
$headers .= "Cc:".$recarr[rc_email]." " . "\r\n";
$headers .= "Content-type: text/html; charset=utf-8" . "\r\n";


$to       = $resarr[re_email];

//cp recruiter
@mail($to, $subject, $content, $headers);




$smarty->assign('title',"Certification & Authorization ");
$smarty->assign('content',"Email sent successfully!<input value=\"back\" onclick=\"history.go(-1)\" type=\"button\" class=\"button-secondary\">");

$smarty->display('header.tpl');


$smarty->display('allleft.tpl');
$smarty->display('announce.tpl');
$smarty->display('allright.tpl');

$smarty->display('footer.tpl');
?>